package edu.cmu.cs.cs214.hw9.client.gui;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import edu.cmu.cs.cs214.hw9.datatypes.User;

/**
 * Renders the friend buttons in the friend screen. 
 */
public class FriendRenderer extends JButton implements ListCellRenderer {
	private static final long serialVersionUID = -7287277286044821406L;

	/**
	 * Renders the friend data as a button with the friend's name on it.
	 */
	public Component getListCellRendererComponent(JList list,
			Object user, int index, boolean isSelected, boolean cellHasFocus) {
		if (cellHasFocus) setBackground(Color.darkGray);
		setText(((User)user).getFullname());
		
		return this;
	}
}
